package com.quanshu.shop.goods.custom;

import android.content.Context;
import android.graphics.Rect;
import android.os.Build;
import android.view.View;
import android.view.WindowManager;
import android.widget.PopupWindow;

import com.quanshu.exchange.R;

/**
 * 作者  李哲
 * 创建时间 2018/7/27
 * 邮箱 lizhetongliao@163.com
 * 说明
 **/
public class CartDialogPopupWindow extends PopupWindow {
    public CartDialogPopupWindow(Context context) {
        super(context);
        View view = View.inflate(context, R.layout.popupwindow_cart_dialog, null);
        setContentView(view);
        setWidth(WindowManager.LayoutParams.WRAP_CONTENT);
        setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
        setFocusable(true);
        setTouchable(true);
    }


    @Override
    public void showAsDropDown(View anchor) {
        if (Build.VERSION.SDK_INT >= 24) {
            Rect visibleFrame = new Rect();
            anchor.getGlobalVisibleRect(visibleFrame);
            int height = anchor.getResources().getDisplayMetrics().heightPixels - visibleFrame.bottom;
            setHeight(height);
        }
        super.showAsDropDown(anchor);
    }
}
